﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;

namespace Coolzon.WebServer.Code.ApiControllers
{
    public class ConfigFileController : ApiController
    {
        public HttpResponseMessage Get(string id)
        {
            if (string.Equals(id, "Realtime-ServerApp", StringComparison.CurrentCultureIgnoreCase))
            {
                try
                {
                    string json = System.IO.File.ReadAllText(HttpContext.Current.Server.MapPath("~/Configs/Realtime.ServerApp.json"));
                    return new HttpResponseMessage { Content = new StringContent(json, System.Text.Encoding.UTF8, "application/json") };
                }
                catch(Exception ex)
                {

                }
            }
            else if (string.Equals(id, "ViewerApp", StringComparison.CurrentCultureIgnoreCase))
            {
                try
                {
                    string json = System.IO.File.ReadAllText(HttpContext.Current.Server.MapPath("~/Configs/ViewerApp.json"));
                    return new HttpResponseMessage { Content = new StringContent(json, System.Text.Encoding.UTF8, "application/json") };
                }
                catch (Exception ex)
                {

                }
            }
            return new HttpResponseMessage(HttpStatusCode.NoContent);
        }
    }
}